package com.cssw.fyzb.web.service;

import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.base.web.domain.AjaxPage;
import com.cssw.fyzb.core.dao.text.TextKindDao;
import com.cssw.fyzb.core.model.dodb.SysTextKind;
import com.cssw.fyzb.core.model.dodb.SysText;
import com.ydn.dbframe.plugin.activerecord.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author: tjf
 * @Date: 2020/10/10 15:09
 */
@Service
public class SysTextService {

    @Autowired
    private TextKindDao textKindDao;

    /**
     * 查询文章分类列表
     *
     * @param page
     * @param limit
     * @return
     */
    public AjaxPage listKind(int page, int limit) {
        Page<SysTextKind> pages = textKindDao.listKind(page, limit);
        return AjaxPage.success(pages.getList(), pages.getTotalPage(), pages.getTotalRow());
    }


    /**
     * 新增文章分类
     */
    public AjaxData saveKind(String kindCode,String kindName,Long sysOperId) {
        return AjaxData.success(textKindDao.saveKind(kindCode, kindName, sysOperId));
    }


    /**
     * 修改文章分类
     */
    public AjaxData updateKind(String kindCode, String kindName, Long sysOperId) {
        return AjaxData.success(textKindDao.updateKind(kindCode, kindName, sysOperId));
    }


    /**
     * 删除文章分类
     */
    public AjaxData deleteKind(String kindCode,Long sysOperId) {
        return AjaxData.success(textKindDao.deleteKind(kindCode,sysOperId));
    }


    /**
     * 查询文章列表
     *
     * @param page
     * @param limit
     * @return
     */
    public AjaxPage list(int page, int limit) {
        Page<SysText> pages = textKindDao.list(page, limit);
        return AjaxPage.success(pages.getList(), pages.getTotalPage(), pages.getTotalRow());
    }


    /**
     * 新增文章
     */
    public AjaxData save(String textCode,String textName,String kindCode,String content,String textUrl,Long sysOperId) {
        return AjaxData.success(textKindDao.save(textCode,textName,kindCode,content,textUrl,sysOperId));
    }


    /**
     * 修改文章
     */
    public AjaxData update(String textCode,String textName,String kindCode,String content,String textUrl,Long sysOperId) {
        return AjaxData.success(textKindDao.update(textCode,textName,kindCode,content,textUrl,sysOperId));
    }


    /**
     * 删除文章
     */
    public AjaxData delete(String textCode,Long sysOperId) {
        return AjaxData.success(textKindDao.delete(textCode,sysOperId));
    }
}
